#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N=2e5+3;
ll n,m,A,B,dis[2][N];
vector<int>ve[N];
struct Nod{int op,x;};
int main()
{
	freopen("edge.in","r",stdin);
	freopen("edge.out","w",stdout);
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>m>>A>>B;
	for(int i=1;i<=n;i++)dis[0][i]=dis[1][i]=1e9;
	for(int i=1,x,y;i<=m;i++)cin>>x>>y,ve[x].push_back(y),ve[y].push_back(x);
	queue<Nod>q;q.push({0,1});dis[0][1]=0;
	while(q.size())
	{
		int x=q.front().x,op=q.front().op;q.pop();
		for(int y:ve[x])if(dis[op^1][y]>dis[op][x]+1)dis[op^1][y]=dis[op][x]+1,q.push({op^1,y});
	}
	for(int i=2;i<=n;i++)cout<<min({min(dis[0][i],dis[1][i])*A,dis[0][i]/2*B,dis[1][i]/2*B+A})<<'\n';
}
